<?php

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
class CartController extends Controller
{
    /**
    *商品分类添加页面
    */
    public function getAdd()
    {
        $data = DB::table('shop_cart')->get();
        return view('/admin/cart/add',['data'=>$data]);
    }
    /**
    *执行商品分类添加
    */
    public function postInsert(Request $request)
    {
        
        $arr = $request -> only(['cname','pid']);
        $res = DB::table('shop_cart')->where('id',$arr['pid'])->first();
        $arr['path'] = $res['path'].','.$res['id'];
        //dd($data);
        $res = DB::table('shop_cart')->insert($arr);
        if($res)
            return redirect('/admin/cart/index')->with('success','分类添加成功');
        else
            return redirect('/admin/cart/index')->with('error','分类添加失败');
    }
    public function getIndex()
    {
        $data = DB::table('shop_cart')->get();
    }
}
